<template>
    <dialog class="ue_dialog" ref="dialogRef" :style="dialogStyle">
        <div class="header_line">
            <div class="left"></div>
            <div class="center"></div>
            <div class="right"></div>
        </div>
        <div style="opacity: 1;background-color: #000;">
            <div class="dialog_header">
                <span class="header_title">{{ title }}</span>
                <img class="close_icon" src="../assets/images/dialog/close.png" @click="handleClose">
            </div>
        </div>
        <div class="dialog_content">
            <slot></slot>
            <div class="btn_wrap" v-if="showBtn">
                <div class="confirm" @click="confirmHandle">确定</div>
            </div>
        </div>
    </dialog>
</template>
<script setup>
import { ref, watch, computed } from 'vue';

const props = defineProps({
    title: {
        type: String
    },
    visible: {
        type: Boolean,
        default: false
    },
    showBtn: {
        type: Boolean,
        default: true
    },
    width: {
        type: String,
    }
})
const emit = defineEmits(['update:visible', 'close', 'cancel', 'confirm']);
const dialogRef = ref();
const dialogStyle = ref({});
dialogStyle.value.width = props.width;

const show = computed({
    get() {
        return props.visible;
    },
    set(newValue) {
        emit('update:visible', newValue);
    }
});
watch(() => props.visible, (newVal, oldVal) => {
    if (newVal) {
        show.value = true;
        // dialogRef.value.showModal();
        dialogRef.value.show();
    } else {
        show.value = false;
        dialogRef.value.close();
    }
});
const handleClose = () => {
    emit("close");
    show.value = false;
    dialogRef.value.close();
}
const cancelHandle = () => {
    show.value = false;
    emit("cancel");
}
const confirmHandle = () => {
    emit("confirm")
}
</script>
<style scoped lang="scss">
.ue_dialog {
    height: fit-content;
    min-width: 1120px;
    margin: 0 auto;
    padding: 0;
    border: none;
    background-color: rgba(0, 0, 0, 0);
    position: relative;
    top: -80%;

    &:focus-visible {
        outline: none;
    }

    &::after {
        content: '';
        display: block;
        height: 59px;
        width: 59px;
        background-color: #00FCF9;
        -webkit-clip-path: polygon(0 78%, 100% 78%, 100% 100%, 19% 100%);
        clip-path: polygon(0 78%, 100% 78%, 100% 100%, 19% 100%);
        position: absolute;
        bottom: -11px;
        right: 0px;
        z-index: 999;
    }

    .header_line {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-bottom: 6px;

        .left {
            background-color: #00FCF9;
            width: 100px;
            height: 6px
        }

        .center {
            flex: 1;
            background-color: #0B3B5B;
            height: 2px;
        }

        .right {
            background-color: #00FCF9;
            width: 100px;
            height: 3px
        }
    }

    .dialog_header {
        height: 79px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background-image: url('../assets/images/dialog/pop_up_title_bg.png');
        border: 2px solid #00FCF9;
        border-bottom: none;

        .header_title {
            font-size: 38px;
            font-family: "YouSheBiaoTiHei";
            color: #FFFFFF;
            height: 79px;
            line-height: 79px;
            padding-left: 22px;
            box-sizing: border-box;
        }

        .close_icon {
            width: 41.5px;
            height: 38px;
            margin-right: 26px;
            cursor: pointer;
        }

    }

    .dialog_content {
        padding-left: 38px;
        padding-right: 38px;
        padding-top: 30px;
        max-height: 1200px;
        opacity: 1;
        background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), rgba(12, 111, 111, 0.8);
        border: 2px solid #00FCF9;
        box-shadow: inset 0px 0px 30px 0px #2176A7;

        &::-webkit-scrollbar {
            width: 0;
        }


    }

    .btn_wrap {
        display: flex;
        justify-content: center;
        font-size: 32px;
        padding-bottom: 33px;

        .cancel {
            width: 128px;
            height: 64px;
            box-sizing: border-box;
            border: 2px solid #21E0C5;
            color: #21E0C5;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 3px;
            cursor: pointer;
        }

        .confirm {
            width: 128px;
            height: 64px;
            background: linear-gradient(180deg, #26D9A2 0%, #046F4E 100%);
            color: #CFFAF3;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-left: 14px;
            cursor: pointer;
        }
    }

}
</style>